<template>
  <el-dialog
    :title="title"
    custom-class="dialogXH"
    :visible.sync="visible"
    :width="width"
    :top="top"
    :close-on-click-modal="closeOnClickModal"
    @close="dialogClose"
  >
    <slot />
    <div v-show="buttonShow" slot="footer" class="dialog-footer">
      <div class="footer">
        <el-button size="mini" @click="dialogClose">取 消</el-button>
        <el-button type="primary" size="mini" @click="dialogFormVisible">确 定</el-button>
      </div>
    </div>
  </el-dialog>
</template>
<script>
export default {
  props: {
    title: {
      type: String,
      default: function() {
        return '标题'
      }
    },
    width: {
      type: String,
      default: function() {
        return '40%'
      }
    },
    top: {
      type: String,
      default: function() {
        return '25vh'
      }
    },
    buttonShow: {
      type: Boolean,
      default: function() {
        return true
      }
    },
    closeOnClickModal: {
      type: Boolean,
      default: function() {
        return true
      }
    }
  },
  data() {
    return {
      visible: false
    }
  },
  methods: {
    dialogClose() {
      this.visible = false
      this.$emit('handleClose')
    },
    dialogFormVisible() {
      this.$emit('handleOk')
    }
  }
}
</script>
<style scoped>
/deep/.el-dialog__header{
  background-color: #f2f3f7;
}
/deep/.el-dialog__footer{
  padding: 0;
}
.footer{
  padding: 10px 0 ;
  border-top: 1px solid #f2f3f7;
  text-align: center;
}
</style>
